﻿using System;
using System.Collections.Generic;

namespace ScriptXCompiler
{
    public class ErrorAggregator : IEnumerable<CompileIssue>
    {
        private List<CompileIssue> _issues;

        public bool HasError
        {
            get { return _issues.Count > 0; }
        }

        public ErrorAggregator()
        {
            _issues = new List<CompileIssue>();
        }

        public void AppendIssue(CompileIssue issue)
        {
            _issues.Add(issue);
        }

        public IEnumerator<CompileIssue> GetEnumerator()
        {
            return _issues.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return _issues.GetEnumerator();
        }
    }
}
